package com.example.klinemqflink.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class LocalTimeUtil {
    public static String timestampToDateTime(long timestamp) {

        // 将时间戳转换为 LocalDateTime 对象
        LocalDateTime localDateTime = Instant.ofEpochMilli(timestamp)
                .atZone(ZoneId.systemDefault())
                .toLocalDateTime();

        // 定义日期时间格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");

        // 格式化 LocalDateTime 对象为字符串
        return localDateTime.format(formatter);
    }


    public static long timestampRounding(long time){
        long timestamp = System.currentTimeMillis();
        return timestamp / 60000 * 60000;
    }
}
